/*
Copyright (C) 2009  Raymond Jeon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "gl_lib_include.h"
#include "gl_lib_windows.h"








////////////////////////////////////////////////////////////////////////////////
//	Date : 2003-3-26
//	Update : 
//	Author : Raymond Jeon
//	Parameters
//	Return Value  
//	Remarks 
////////////////////////////////////////////////////////////////////////////////

int GlGetWindowsSystemVersion()
{
   OSVERSIONINFOEX osvi;
   BOOL bOsVersionInfoEx;

   // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
   //
   // If that fails, try using the OSVERSIONINFO structure.

   ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

   bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi);
   if(bOsVersionInfoEx == FALSE)
   {
      // If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.

      osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
      if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) 
         return WINDOWS_UNKNOWN;
   }

   switch (osvi.dwPlatformId)
   {
      case VER_PLATFORM_WIN32_NT:

      // Test for the product.

         if ( osvi.dwMajorVersion <= 4 )
			 return WINDOWS_NT;

         if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
			 return WINDOWS_2000;

         if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
			 return WINDOWS_XP;

         break;
      case VER_PLATFORM_WIN32_WINDOWS:

         if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
         {
			 return WINDOWS_95;
         } 

         if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
         {
			 return WINDOWS_98;
         } 

         if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
         {
			 return WINDOWS_ME;
         } 
         break;

      case VER_PLATFORM_WIN32s:
		  return WINDOWS_WIN32S;
         break;
   }
   return WINDOWS_UNKNOWN; 
}






